<template>
  <el-radio-group v-model="formValue" v-bind="$attrs" v-on="$listeners">
    <template v-if="$attrs.__config__.optionType=='button'">
      <el-radio-button
        v-for="item in __slot__.options"
        :key="item.value"
        :label="item.value"
        :value="item.value"
        :border="$attrs.__config__.border"
      >{{ item.label }}</el-radio-button>
    </template>
    <template v-else>
      <el-radio
        v-for="item in __slot__.options"
        :key="item.value"
        :label="item.value"
        :value="item.value"
        :border="$attrs.__config__.border"
      >{{ item.label }}</el-radio>
    </template>
  </el-radio-group>
</template>

<script>
export default {
  name: "form-radio-group",
  model: {
    prop: "value", // 绑定的值，通过父组件传递
    event: "update"
  },
  props: {
    value: {
      type: [String, Number],
      default: ""
    },
    // 外层组件内部组件的数据
    __slot__: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    formValue: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("update", val);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
</style>